def partition(numbers, number): # DO NOT modify this line 
    list1 = []
    list2 = [number]
    for i in numbers:
        if i < number:
            list1.append(i)
        else:
            list2.append(i)
    numbers.clear()
    for i in list1+list2:
        numbers.append(i)
    # TODO: add your code here
    return numbers.index(number)# You can modify or delete this line

# === DO NOT modify the code below ===
def main():
    numbers = [ eval(x) for x in input().split() ]
    x = eval(input())
    index = partition(numbers, x)
    print(" ".join(map(str,numbers)))
    print(index)
    
if __name__ == "__main__":
    main()